package cn.edu.hqu.javaee;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import cn.edu.hqu.javaee.domain.Ingredient;
import cn.edu.hqu.javaee.domain.Ingredient.Type;
import cn.edu.hqu.javaee.repository.IngredientRepository;


@SpringBootApplication
public class CourseSystemApplication {

	public static void main(String[] args) {
		SpringApplication.run(CourseSystemApplication.class, args);
	}
	@Bean
	public CommandLineRunner dataLoader(IngredientRepository repo) {
		return new CommandLineRunner() {
			
			@Override
			public void run(String... args) throws Exception {
				 repo.save(new Ingredient("DMaths", "离散数学", Type.MATH));
			     repo.save(new Ingredient("PMath", "随机数学", Type.MATH));
			     repo.save(new Ingredient("AMath", "高等代数", Type.MATH));
			     repo.save(new Ingredient("CMath", "高等数学1", Type.MATH));
			     repo.save(new Ingredient("CMath2", "高等数学2", Type.MATH));
			     repo.save(new Ingredient("JW", "Javaweb", Type.LANGUAGE));
			     repo.save(new Ingredient("PT", "Phython", Type.LANGUAGE));
			     repo.save(new Ingredient("CPP", "C++", Type.LANGUAGE));
			     repo.save(new Ingredient("S", "Swift", Type.LANGUAGE));
			     repo.save(new Ingredient("J", "Java", Type.LANGUAGE));

			}
		
		};
	}

}
